﻿namespace Lr.Templating.FluentMapping
{
    /// <summary>
    /// Abstract implementation of <see cref="ITemplateMappingBuilder"/>,
    /// which defines a template mapping builder,
    /// a construct that facilitates the mapping fluent api.
    /// </summary>
    internal abstract class TemplateMappingBuilderBase : ITemplateMappingBuilder
    {
        /// <summary>
        /// Constructs a new <see cref="TemplateMappingBuilderBase"/> instance.
        /// </summary>
        /// <param name="template">The template for which we're building a mapping.</param>
        /// <param name="placeholder">The placholder attached to the mapping we're building.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="template"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="placeholder"/> is null, empty or only exists of white spaces.</exception>
        internal TemplateMappingBuilderBase(ITemplate template, string placeholder)
        {
            ThrowIf.Null(() => template);
            ThrowIf.NullOrEmpty(() => placeholder);

            _template = template;
            _placeholder = placeholder;
        }

        /// <summary>
        /// Gets the template for which we're building a mapping.
        /// </summary>
        public ITemplate Template { get { return _template; } }
        private readonly ITemplate _template;

        /// <summary>
        /// Gets the placeholder attached to the mapping we're building.
        /// </summary>
        public string Placeholder { get { return _placeholder; } }
        private readonly string _placeholder;
    }
}
